﻿<%= form_for(@user, :url => my_account_path, :html => {:class => 'well fl'}) do |f| %>
  
  <h3>Basic information</h3>
  
  <% if @user.errors.any? %>
    <div class="alert alert-block alert-error fade in">
      <h4 class="alert-heading"><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h4>
      <ul>
        <% @user.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
      </ul>
    </div>
  <% end %>
  
  <div>
    <%= f.label :username %>
    <%= f.text_field :username %>
  </div>
  
  <div>
    <%= f.label :email %>
    <%= f.text_field :email %>
  </div>
  
  <div>
    <%= f.label :password %>
    <%= f.password_field :password %>
  </div>
  
  <div>
    <%= f.label :password_confirmation %>
    <%= f.password_field :password_confirmation %>
  </div>


  <%= f.fields_for :profile do |builder| %>
    <h3>Profile</h3>
    
    <% if @user.profile.errors.any? %>
      <div class="alert alert-block alert-error fade in">
        <h4 class="alert-heading"><%= pluralize(@user.profile.errors.count, "error") %> prohibited this user from being saved:</h4>
        <ul>
          <% @user.profile.errors.full_messages.each do |msg| %>
            <li><%= msg %></li>
          <% end %>
        </ul>
      </div>
    <% end %>
    
    <div>
      <%= builder.label :name %>
      <%= builder.text_field :name %>
    </div>
    
    <div>
      <%= builder.label :bio %>
      <%= builder.text_area :bio, :rows => 4, :cols => 30 %>
    </div>
    
    <div>
      <%= builder.label :location %>
      <%= builder.text_field :location %>
    </div>
    
    <div>
      <%= builder.label :website %>
      <%= builder.text_field :website %>
    </div>

  <% end %>

  <%= f.fields_for :settings do |builder| %>
    <h3>Settings</h3>

    <% if @user.settings.errors.any? %>
      <div class="alert alert-block alert-error fade in">
        <h4 class="alert-heading"><%= pluralize(@user.settings.errors.count, "error") %> prohibited this user from being saved:</h4>
        <ul>
          <% @user.settings.errors.full_messages.each do |msg| %>
            <li><%= msg %></li>
          <% end %>
        </ul>
      </div>
    <% end %>
    
    <div>
      <%= builder.label :country %>
      <%= builder.text_field :country %>
    </div>
    
    <div>
      <%= builder.label :language %>
      <%= builder.select :language, Setting.options_languages %>
    </div>
    
    <div>
      <%= builder.label :timezone %>
      <%= builder.text_field :timezone %>
    </div>
  <% end %>

  <div class="actions">
    <br><%= f.submit 'Send', :class => 'btn btn-primary' %> | <%= link_to 'Back', users_path, :class => 'btn' %></br>
  </div>
<% end %>